-
Notifications
You must be signed in to change notification settings - Fork 16.3k
fix unreachable mypy warnings for microsoft/azure #53647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gopidesupavan
merged 3 commits into
apache:main
from
fweilun:fix-unreachable-microsoft-azure
Aug 12, 2025
Merged
fix unreachable mypy warnings for microsoft/azure #53647
gopidesupavan
merged 3 commits into
apache:main
from
fweilun:fix-unreachable-microsoft-azure
Aug 12, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4f7b60e to
987a561
Compare
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py
Outdated
Show resolved
Hide resolved
gopidesupavan
requested changes
Jul 27, 2025
Member
gopidesupavan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update WasbAsyncHook changes in different PR.
Contributor
Author
|
Hi, I’m currently abroad and will update the PR right after Aug 5. Will handle it as soon as I’m back — thanks! |
This was referenced Aug 6, 2025
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/msgraph.py
Show resolved
Hide resolved
gopidesupavan
approved these changes
Aug 11, 2025
Member
|
conflicts to resolve :) |
Member
|
rebase ? |
8d30873 to
b74960e
Compare
Contributor
Author
|
@gopidesupavan Thanks for reviewing. I’ve updated accordingly. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related: #53395
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:106: error: Statement is unreachable [unreachable]
self.connections_prefix = connections_prefix
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:110: error: Statement is unreachable [unreachable]
self.variables_prefix = variables_prefix
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:114: error: Statement is unreachable [unreachable]
self.config_prefix = config_prefix
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:151: error: Statement is unreachable [unreachable]
return None
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:163: error: Statement is unreachable [unreachable]
return None
providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:175: error: Statement is unreachable [unreachable]
return None
All of the variables (connections_prefix, variables_prefix, config_prefix) are allowed to be None, as seen in existing test cases. However, the original code only implied string types, leading to unreachable MyPy errors.
We resolved this by:
• Explicitly annotating input arguments as str | None
• Using safe conditional initialization with
original:
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py:599: error: Statement is unreachable [unreachable]
conn = await sync_to_async(self.get_connection)(self.conn_id)
The code was flagged as unreachable by MyPy because self.blob_service_client was not annotated to allow None.
As a result, the following condition is always True from the type checker’s perspective:
To fix this, we explicitly annotated the attribute to allow None:
This makes the conditional logic valid and resolves the MyPy warning.
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py:463: error: Statement is unreachable [unreachable]
request_information.content = data
Added bytes to the input type annotation to fix a type mismatch.
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/synapse.py:129: error: Statement is unreachable [unreachable]
self.hook.cancel_job_run(
Annotated self.job_id as Any to match its default value None and resolve the type warning.
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/msgraph.py:260: error: Statement is unreachable [unreachable]
if append_result_as_list_if_absent:
The is condition was unreachable due to the static type of results. Changing its annotation to Any resolves the issue.